<?php

/*
 * Action 2$
 *
 * +1 Card
 * +1 Action
 * Reveal the top card of your deck. If it's a Curse, Ruins, Shelter, or Victory card, put it into your hand.
 * 
 */

class Vagrant extends Card implements iAction, iKingdom, iDarkAges {

    public function __construct() {
        parent::__construct("Vagrant", 2);
        $this->undoPlay = false;
        $this->undoBuy = true;
    }

    public function getDescription() {
        return array(
            "+1 Card",
            "+1 Action",
            "Reveal the top card of your deck. If it's a Curse, Ruins, Shelter, or Victory card, put it into your hand.");
    }

    public function play(Game $game, $isRealCard) {
        $drawed_cards = $game->drawCards(1);
        $game->addActions(1);
        ScreenDisplay::addScreenMessage($game, true, "get +1 action  and draw " . nicePrint($drawed_cards), "gets +1 action and draws " . sizeof($drawed_cards) . " cards");

        $card = $game->peekCardFromDrawDeck();
        if ($card instanceof iCurse || $card instanceof iRuin || $card instanceof iVictory || $card instanceof iShelter) {
            $game->drawCards(1);
            ScreenDisplay::addScreenMessage($game, true, "reveal " . nicePrint($card) . " and put it in your hand ", "reveals " . ScreenDisplay::$LMSG . " and puts it in his hand ");
        } else if ($card) {
            ScreenDisplay::addScreenMessage($game, true, "reveal " . nicePrint($card) . " and put it back on your deck ", "reveals " . ScreenDisplay::$LMSG . " and puts it back on his deck ");
        } else {
            ScreenDisplay::addScreenMessage($game, true, "reveal nothing", "reveals nothing");
        }
        $game->cardActionFinished();
        return true;
    }

}

?>